import fetch from 'common/src/utils/fetch'
import UTILS from "common/src/utils/utils";

/**
 * 删除
 */
function delete_(roundId, idList) {
    return fetch({
        url: `/api/electionservice/elecRoundStu/${roundId}`,
        method: 'delete',
        data: idList
    });
}

/**
 * 条件删除
 */
function deleteByCondition(condition) {
    return fetch({
        url: `/api/electionservice/elecRoundStu/deleteByCondition`,
        method: 'delete',
        data: condition
    });
}

/**
 * 新增
 */
function add(roundId, idList,mode) {
    return fetch({
        url: `/api/electionservice/elecRoundStu/${roundId}/${mode}`,
        method: 'put',
        data: idList
    });
}
/**
 * 条件添加
 * @param {} condition 
 */
function addByCondition(condition) {
    return fetch({
        url: '/api/electionservice/elecRoundStu/addByCondition',
        method: 'put',
        data: condition
    });
}

/**
 * 查询列表
 */
function searchList(data) {
    return fetch({
        url: '/api/electionservice/elecRoundStu/page',
        method: 'post',
        data: data
    });
}

function initData(data) {
    return fetch({
        url: '/api/electionservice/elecRoundStu/initData',
        method: 'post',
        data: data
    });
}

/**
 * 下载模板
 */
function downTemplate(){
    return fetch({
        url: `/api/electionservice/elecRoundStu/download`,
        method: 'get',
        responseType: 'blob'
    }).then(res => {
        UTILS.downloadFile(res, '可选课学生名单.xls', 'application/vnd.ms-excel;charset=utf-8');
    });
}

export default {
    "delete_": delete_,
    "deleteByCondition": deleteByCondition,
    "add": add,
    "addByCondition": addByCondition,
    "searchList": searchList,
    "downTemplate": downTemplate
}
